import baseUrl from './baseUrl.js'
import store from '../store/index.js'

export const getInviteCode = ()=> {
	return new Promise((res,rej)=> {
		uni.request({
			url: baseUrl + '/inviteCode/getInviteCode',
			method:'GET',
			header: {
				'token': uni.getStorageSync('token'),
				'Content-type': 'application/x-www-form-urlencoded'
			},
			data: {
				role: store.state.userInfo.role
			},
			success(response) {
				res(response)
			},
			fail(err) {
				rej(err)
				uni.showToast({
					title:'数据获取失败',
					icon:'error'
				})
			}
		})
	})
}


export const getInviteCodeAndSend = data => {
	return new Promise((res,rej)=> {
		uni.request({
			url: baseUrl + '/inviteCode/getInviteCodeAndSend',
			method:'GET',
			header: {
				'token': uni.getStorageSync('token'),
				'Content-type': 'application/x-www-form-urlencoded'
			},
			data,
			success(response) {
				res(response)
			},
			fail(err) {
				rej(err)
				uni.showToast({
					title:'数据获取失败',
					icon:'error'
				})
			}
		})
	})
}